package com.gongpingjialoan.utility;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Administrator on 2016/8/9.
 */
public class GuidePreferences {

    //偏好文件名
    public static final String SHAREDPREFERENCES_NAME = "guide";

    /**
     *
     * @param context
     * @return 是否已经引导过 true引导过了 false未引导
     */
    public static boolean activityIsGuided(Context context, String tag) {
        if (context == null || tag == null || "".equalsIgnoreCase(tag)) return false;
        SharedPreferences mSharedPreferences = context.getSharedPreferences(SHAREDPREFERENCES_NAME,Context.MODE_WORLD_READABLE);
        return mSharedPreferences.getBoolean(tag,false);
    }

    /**
     *
     *
     * @param context
     * @param tag
     */
    public static void setIsGuided(Context context, String tag) {
        if (context == null || tag == null || "".equalsIgnoreCase(tag)) return;
        context.getSharedPreferences(SHAREDPREFERENCES_NAME, Context.MODE_WORLD_READABLE)//保存修改后的值
                .edit()
                .putBoolean(tag, true)
                .commit();
    }
}
